#include "CMainMenuState.h"
#include "..\Objects\CButton.h"
#include "..\..\external_libs\SFML\include\SFML\Graphics\Text.hpp"
#include "..\Managers\CInputManager.h"

CMainMenuState::CMainMenuState(sf::RenderTarget& rt, CInputManager& input) : IGameState(rt, input)
{
	m_pRunButton = NULL;
}
CMainMenuState::~CMainMenuState(void)
{
}

void CMainMenuState::RunTest(void)
{
	m_pRunButton->ChangeText("That worked");
}

void CMainMenuState::Enter(void)
{
	m_pRunButton = new CButton("This is a test", 0, 0, 100, 50);
}
void CMainMenuState::Exit(void)
{
	if(m_pRunButton)
	{
		delete m_pRunButton;
		m_pRunButton = NULL;
	}
}
void CMainMenuState::Render(void)
{	
	m_pRenderTarget->draw(*m_pRunButton);
}
void CMainMenuState::Update(sf::Time timeElapsed)
{
	if(m_pRunButton->CanBeSelected() && m_pRunButton->CheckCollision(m_pInput->GetMouseState().m_Pos))
	{
		m_pRunButton->SetSelected(true);
	}
	else
	{
		m_pRunButton->SetSelected(false);
	}
}
bool CMainMenuState::Input()
{
	
	if(m_pInput->GetMouseState().m_bPressed && m_pInput->GetMouseState().m_eButton == eLEFT)
	{
		if(m_pRunButton->IsSelected())
		{
			RunTest();
		}
	}

	return true;
}